package com.dragon.design.pattern.structural.delegate;

/**
 * 鸭子超类
 *
 * @author dragon
 * @since 2019/11/14
 */
public abstract class AbstractDuck {

    protected FlyBehavior flyBehavior;

    protected QuackBehavior quackBehavior;

    protected AbstractDuck(FlyBehavior flyBehavior, QuackBehavior quackBehavior) {
        this.flyBehavior = flyBehavior;
        this.quackBehavior = quackBehavior;
    }

    protected AbstractDuck() {

    }

    /**
     * 飞行
     */
    public void doFly() {
        flyBehavior.fly();
    }

    /**
     * 叫
     */
    public void doQuack() {
        quackBehavior.quack();
    }

    /**
     * 展示
     */
    public abstract void display();

    /**
     * 游泳
     */
    public void swim() {
        System.out.println("All ducks float, even decoys!");
    }
}
